% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Replication "Deconstructing the Yield Curve"
% Crump and Gospodinov (2024)
% Date: 26-JUL-2024
% Function for making (approximate) bond returns following BR2020
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%    
function [bs1Xrn,bs1Xrn4] = makeReturnsBR(bs1YldBH)
    % if p.H==1
        bs1Xrn = NaN(size(bs1YldBH));
        for n = 2:15
            tmp = -(n-1/4)*bs1YldBH(2:end,2+n)+n*bs1YldBH(1:end-1,2+n)-(1/4)*bs1YldBH(1:end-1,1);
            bs1Xrn(2:end,n+2) = tmp;
        end
    % if p.H==4
        bs1Xrn4 = NaN(size(bs1YldBH));
        for n = 2:15
            tmp = -(n-1)*bs1YldBH(4+1:end,1+n)+n*bs1YldBH(1:end-4,2+n)-bs1YldBH(1:end-4,3);
            bs1Xrn4(4+1:end,n+2) = tmp;
        end
end